import { useAppStore } from "@/store";
import { DirectiveBinding } from "vue";

const checkPermission = (el: HTMLElement, binding: DirectiveBinding)=>{
    let store = useAppStore();
    const { value } = binding;
    const permissionList = store.state.permissionList;
    const hasPermission = permissionList.includes(value);
    if(!hasPermission){
        el.style.display = 'none';
    }else{
        el.removeAttribute('disabled');
    }
};
export default {
    mounted(el: HTMLElement, binding: DirectiveBinding){
        checkPermission(el, binding);
    },
    updated(el: HTMLElement, binding: DirectiveBinding){
        checkPermission(el, binding);
    }
} as any;
